
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@iter-tools/queue
Advanced tools
A simple es6 linked FIFO queue in the pattern of es6 Map
and Set
. Includes typescript libdefs. Suitable for node or browser environments. Supports native es imports in node > 13.2
.
const Queue = require('@iter-tools/queue'); // OR
import Queue from '@iter-tools/queue';
const q = new Queue([1, 2, 3]);
q.push(4);
[...q]; // [1, 2, 3, 4]
q.size; // 4
q.shift(); // 1
q.shift(); // 2
q.shift(); // 3
q.shift(); // 4
q.size; // 0
q.shift(); // undefined
Until Typescript supports package exports you must enable esModuleInterop
to use this module.
/**
* The values which has been in the queue longest is its head.
* The most recent addition is the tail.
*/
class Queue<T> {
/**
* Returns true if `inst` is a Queue.
* This does not necessarily imply instanceof, but the check
* is safe across frame boundaries, as it is done by looking for
* Queue[Symbol.for('@iter-tools/queue')]
*/
static isQueue(inst): boolean;
/**
* An optional iterable of `values` to be pushed into the queue
* in sequence. If `null` or `undefined` are passed the queue will
* have no initial values.
*/
constructor(values?: Iterable<T>);
/**
* The number of values in the queue
*/
size: number;
/**
* Empties the queue of all values.
*/
clear();
/**
* Returns the value at the head of the queue.
*/
peek(): T | undefined;
/**
* Removes the value at the head of the queue and returns it.
*/
shift(): T | undefined;
/**
* Adds `value` at the tail of the queue.
*/
push(value: T);
/**
* Calls `cb(value, index, queue)` for each value in the queue.
*/
forEach(
cb: (value: T, index: number, queue: Queue) => any,
);
/**
* Yields sequential 0-based indexes, one for each queued value.
* The index 0 indicates the head.
*/
keys(): IterableIterator<number>;
/**
* Yields the queued values from head to tail.
*/
values(): IterableIterator<T>;
/**
* Yields `[index, value]` tuples for each value in the queue.
*/
entries(): IterableIterator<[number, T]>;
/**
* The default iterator. Equivalent to `values()`.
*/
[Symbol.iterator](): IterableIterator<T>;
}
FAQs
An es6-style iterable queue
The npm package @iter-tools/queue receives a total of 36 weekly downloads. As such, @iter-tools/queue popularity was classified as not popular.
We found that @iter-tools/queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.